<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">

<head>
    <meta charset="UTF-8">
    <title>企业员工管理-工资结算</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="static/css/font.css">
    <link rel="stylesheet" href="static/css/xadmin.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="static/lib/layui/layui.js"></script>
    <script type="text/javascript" src="static/js/xadmin.js"></script>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>工资管理</a>
        <a>
          <cite>工资结算</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body layui-anim layui-anim-up">
    <span style="font-size: 18px;">按月份结算所有员工工资：</span><br>
    <br>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">选择月份</label>
            <div class="layui-input-inline">
                <input id="allDate" lay-verify="date" autocomplete="off" placeholder="请输入月份" class="layui-input" type="text" readonly>
            </div>

            <div class="layui-input-inline">
                <button class="layui-btn" lay-submit="" lay-filter="allAettlement">一键结算</button>
            </div>
        </div>
    </form>
</div>
<hr>
<hr>
<div class="x-body layui-anim layui-anim-up">
    <span style="font-size: 18px;">结算指定员工工资：</span><br><br>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">选择月份</label>
            <div class="layui-input-inline">
                <input id="date" lay-verify="date" autocomplete="off" placeholder="请输入月份" class="layui-input" type="text" readonly>
            </div>

            <label class="layui-form-label">输入工号</label>
            <div class="layui-input-inline">
                <input name="d_remark" id="eAccount" lay-verify="dRemarkVerify" autocomplete="off" placeholder="请输入工号"
                       class="layui-input" type="text">
            </div>

            <div class="layui-input-inline">
                <button class="layui-btn" lay-submit="" lay-filter="aettlement">工资结算</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        //年月范围
        laydate.render({
            elem: '#allDate'
            , type: 'month'
        });
        //年月范围-->
        laydate.render({
            elem: '#date'
            , type: 'month'
        });

        //自定义验证规则
        form.verify({
            dRemarkVerify: function(value){
                // 验证特殊字符
                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                value = value.replace(" ","");
                if(value.length == 0){
                    return '工号不能为空';
                }
                if(pattern.test(value)){
                    return '工号不能包含特殊字符';
                }
            }
        });


        // 监听提交
        form.on('submit(aettlement)', function (data) {
            $.ajax({
                type: 'post',
                url: 'salarySettlementByAcount.do',
                data: {
                    "date": $("#date").val(),
                    "eAccount": $("#eAccount").val(),
                },
                dataType: 'json',
                success: function (result) {
                	if(result.type=="success"){
                        layer.alert(result.msg, {title: '信息提示'});
                	}else{
                        layer.alert(result.msg, {title: '信息提示'});
                	}
                }
            });
            return false;
        });

        // 监听提交
        form.on('submit(allAettlement)', function (data) {
            $.ajax({
                type: 'post',
                url: 'salarySettlementAll.do',
                data: {
                    "date": $("#allDate").val(),
                },
                dataType: 'json',
                success: function (result) {
                	if(result.type=="success"){
                		 layer.alert(result.msg, {title: '信息提示'});
                	}else{
                		 layer.alert(result.msg, {title: '信息提示'});
                	}     
                }
            });
            return false;
        });
    });
</script>

</body>
</html>